<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup">
  <lv-form-item>
    <lv-form-label lvRequired>{{ 'common_name_label' | i18n }}</lv-form-label>
    <lv-form-control [lvErrorTip]="nameErrorTip">
      <input lv-input type="text" formControlName="clusterName" />
    </lv-form-control>
  </lv-form-item>
  <ng-container *ngIf=" !isEdit || (isEdit && [1, 2].includes(drawData.generatedType))">
    <lv-form-item>
      <lv-form-label lvRequired>{{
        'common_equipment_type_label' | i18n
        }}</lv-form-label>
      <lv-form-control>
        <lv-select [lvOptions]='deviceTypeOptions' formControlName="deviceType" lvValueKey="value"
          [lvDisabled]="!!drawData"></lv-select>
        <span *ngIf="formGroup.get('deviceType').value === dataMap.poolStorageDeviceType.OceanProtectX.value">
          <i lv-icon="lv-icon-status-info" lvColorState='true' class="type-icon"></i>
          <span class="text-middle"
            style="margin-left:4px">{{(isDecouple?'common_equipment_type_tip_label':'common_equipment_type_xseries_tip_label')
            | i18n}}</span>
        </span>
      </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="formGroup.get('deviceType').value !== dataMap.poolStorageDeviceType.Server.value">
      <lv-form-label lvRequired>{{
        'common_ip_address_label' | i18n
        }}</lv-form-label>
      <lv-form-control [lvErrorTip]="ipErrorTip">
        <input lv-input type="text" formControlName="ip" />
        <p class="aui-text-help-sm help-line-height" *ngIf="isEdit">
          <i lv-icon="lv-icon-status-info" lvColorState='true' style="margin-right: 8px"></i>
          <span>{{'system_storage_device_ip_tip_label' | i18n}}</span>
        </p>
      </lv-form-control>
    </lv-form-item>
    <lv-form-item *ngIf="formGroup.get('deviceType').value === dataMap.poolStorageDeviceType.Server.value">
      <lv-form-label lvRequired>
        {{'common_ip_label' | i18n}}
      </lv-form-label>
      <lv-form-control>
        <lv-select [lvOptions]="ipOptions" lvValueKey="value" formControlName="ip" lvShowFilter lvFilterKey="label"
          lvFilterMode="contains"></lv-select>
      </lv-form-control>
    </lv-form-item>
    <ng-container *ngIf="formGroup.get('deviceType').value !== dataMap.poolStorageDeviceType.Server.value">
      <lv-form-item>
        <lv-form-label lvRequired>{{ 'common_port_label' | i18n }}</lv-form-label>
        <lv-form-control [lvErrorTip]="portErrorTip">
          <input lv-input type="text" formControlName="port" />
        </lv-form-control>
      </lv-form-item>
      <lv-form-item>
        <lv-form-label lvRequired>{{
          'common_username_label' | i18n
          }}</lv-form-label>
        <lv-form-control [lvErrorTip]="userNameErrorTip">
          <input lv-input type="text" formControlName="username"
            placeholder="{{'system_add_backup_placeholder_label' | i18n}}" />
        </lv-form-control>
      </lv-form-item>
      <lv-form-item>
        <lv-form-label [lvRequired]="changedName">{{
          'common_password_label' | i18n
          }}</lv-form-label>
        <lv-form-control [lvErrorTip]="passwordErrorTip">
          <aui-inupt-with-eye formControlName="password" placeholder=""></aui-inupt-with-eye>
        </lv-form-control>
      </lv-form-item>
    </ng-container>
  </ng-container>
</lv-form>